package org.osami.utils;

import android.util.Log;

public class Logger {
	String tag = "org.osami";
	String prefix = "";

	public Logger(String aPrefix) {
		this.prefix = aPrefix;
	}

	protected void log(int aPriority, String aMsg) {
		Log.println(aPriority, tag, aMsg);
	}

	protected void log(int aPriority, Object... aArgs) {
		String msg = "";
		if(prefix.length() > 0){
			msg = prefix + ">";
		}
		
		for (int i = 0; i < aArgs.length; i++) {
			msg = msg.concat(aArgs[i].toString());
			if (i < aArgs.length-1) {
				msg = msg.concat(" ");
			}
		}
		
		log(aPriority, msg);
	}

	protected void logf(int aPriority, String aFormat, Object... aArgs) {
		log(aPriority, String.format(aFormat, aArgs));
	}

	// Public APIs ================================
	public void d(Object... aArgs) {
		log(Log.DEBUG, aArgs);
	}

	public void df(String aFormat, Object... aArgs) {
		logf(Log.DEBUG, aFormat, aArgs);
	}
	
	public void w(Object... aArgs) {
		log(Log.WARN, aArgs);
	}

	public void wf(String aFormat, Object... aArgs) {
		logf(Log.WARN, aFormat, aArgs);
	}
	
	public void e(Object... aArgs) {
		log(Log.ERROR, aArgs);
	}

	public void ef(String aFormat, Object... aArgs) {
		logf(Log.ERROR, aFormat, aArgs);
	}

	
}